﻿Imports Microsoft.DirectX
Public Class LandschaftstexturBrücke
    Inherits ObjektLandschaftsTextur
    ''' <summary>
    ''' 0=   1=+N   2=+N+O   3=+N+S   4=+N+O+S   5=+N+O+S+W
    ''' </summary>
    ''' <remarks></remarks>
    Dim ÜbergangsMeshs(5) As Objekt3D


    Public Sub New()
        ID = "BRÜCKE"
        Landschaftsname = "Brücke"
        Deckung = 0
        Tarnung = False
        KP = -1

        Select Case My.Settings.TerrainStyle
            Case TerrainStyle.AdvanceWarsDC, TerrainStyle.CommanderWars2
                ÜbergängeLaden("Brücke")
                TexturenLaden(New String() {"BRÜCKE", "BRÜCKE+N+S", "BRÜCKE+O+W", "BRÜCKE+N+S+W", "BRÜCKE+N+O+S", "BRÜCKE+N+O+S+W", "BRÜCKE+N+O+W", "BRÜCKE+O+S+W", "BRÜCKE+W", "BRÜCKE+O", "BRÜCKE+S", "BRÜCKE+N", "BRÜCKE+S+W", "BRÜCKE+O+S", "BRÜCKE+N+W", "BRÜCKE+N+O"})
            Case Else
                TexturenLaden(New String() {"BRÜCKE", "BRÜCKE+N+S", "BRÜCKE+O+W", "BRÜCKE+N+S+W", "BRÜCKE+N+O+S", "BRÜCKE+N+O+S+W", "BRÜCKE+N+O+W", "BRÜCKE+O+S+W", "BRÜCKE+W", "BRÜCKE+O", "BRÜCKE+S", "BRÜCKE+N", "BRÜCKE+S+W", "BRÜCKE+O+S", "BRÜCKE+N+W", "BRÜCKE+N+O"})
        End Select

        Normal = 0
        Ausrichtungslandschaften = New String() {"FLUSS", "SEE", "RIFF", "STRAND", "SUMPF", "RAUESEE", "NEBEL"}

        If My.Settings.draw3D Then
            Ini3D()
        End If
    End Sub
    Public Overrides Function DrawSpecialStyle(ByVal BildID As Integer, ByVal Fog As Nebelarten, ByVal Alpha As Integer, ByVal X As Integer, ByVal Y As Integer) As Boolean
        Select Case My.Settings.TerrainStyle
            Case TerrainStyle.CommanderWars2, TerrainStyle.AdvanceWarsDC
                Return DrawSeeUndTerrain(Alpha, Fog, BildID, X, Y, 0)
            Case Else
                Return False
        End Select
    End Function


    Public Overrides Sub Malen3D(ByVal p_MatCube As Microsoft.DirectX.Matrix, ByVal Landschaft As ObjektLandschaft)
        'Ganz normal Wasser als untergrund malen.
        Malen3D(p_MatCube, "SEE", Landschaft)
        'BrückenMesh malen
        Dim ind As Integer = 0
        Dim Rot As Single = 0
        Dim Ausr As String = AusrichtungVereinfachen(AusrichtungInvertieren(getAusrichtung(Landschaft.KooX, Landschaft.KooY, Objektverwalter.Spielfeld).ToUpper), Rot)
        Select Case Ausr
            Case ""
                ind = 0
            Case "+N"
                ind = 1
            Case "+N+O"
                ind = 2
            Case "+N+S"
                ind = 3
            Case "+N+O+S"
                ind = 4
            Case "+N+O+S+W"
                ind = 5
        End Select
        Dim Mat As Matrix = Matrix.RotationY(Rot)
        Mat.M41 = p_MatCube.M41 + 0.5
        Mat.M42 = p_MatCube.M42
        Mat.M43 = p_MatCube.M43 + 0.5
        ÜbergangsMeshs(ind).Malen(Mat)
    End Sub

    Public Overrides Sub Ini3D()
        ÜbergangsMeshs(0) = New Objekt3D()
        ÜbergangsMeshs(1) = New Objekt3D()
        ÜbergangsMeshs(2) = New Objekt3D()
        ÜbergangsMeshs(3) = New Objekt3D()
        ÜbergangsMeshs(4) = New Objekt3D()
        ÜbergangsMeshs(5) = New Objekt3D()
        ÜbergangsMeshs(0).MeshBildLaden(My.Settings.Resourcenpfad + "Landschaften\Meshes\Brücke.x")
        ÜbergangsMeshs(1).MeshBildLaden(My.Settings.Resourcenpfad + "Landschaften\Meshes\Brücke+N.x")
        ÜbergangsMeshs(2).MeshBildLaden(My.Settings.Resourcenpfad + "Landschaften\Meshes\Brücke+N+O.x")
        ÜbergangsMeshs(3).MeshBildLaden(My.Settings.Resourcenpfad + "Landschaften\Meshes\Brücke+N+S.x")
        ÜbergangsMeshs(4).MeshBildLaden(My.Settings.Resourcenpfad + "Landschaften\Meshes\Brücke+N+O+S.x")
        ÜbergangsMeshs(5).MeshBildLaden(My.Settings.Resourcenpfad + "Landschaften\Meshes\Brücke+N+O+S+W.x")
    End Sub

    Public Overrides Sub Tick()

    End Sub
End Class
